package com.hmall.api.interceptor;

import cn.hutool.core.util.ObjectUtil;
import com.hmall.common.utils.UserContext;
import feign.RequestInterceptor;
import feign.RequestTemplate;

public class UserInfoFeignInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
        Long userId = UserContext.getUser();
        if (ObjectUtil.isNotNull(userId)){
            requestTemplate.header("user-info", userId.toString());
        }
    }
}
